import sys
import pandas as pd

# 准备初始参数
sheetClassName = sys.argv[1] + "Sheet"
dataClassName = sys.argv[1] + "Data"
excelPath = sys.argv[2]
csTemplatePath = sys.argv[3]
csTargetPath = sys.argv[4]

if excelPath == "":
    sys.exit(1)

# 读取表格字段
df = pd.read_excel(excelPath, sheet_name=0, header=None)
title_row = df.iloc[0]
type_row = df.iloc[1]
chinese_row = df.iloc[2]

variable = ""
for (index1, value1), (index2, value2), (index3, value3) in zip(title_row.items(), type_row.items(), chinese_row.items()):
    variable += f"       public {value2} {value1}; // {value3}\n"  # 组合单元格值


# 替换文件内容
with open(csTemplatePath, 'r', encoding='utf-8') as file:
    template_content = file.read()
template_content = template_content.replace("$SheetClassName", sheetClassName)
template_content = template_content.replace("$DataClassName", dataClassName)
template_content = template_content.replace("$Variable", variable)
with open(csTargetPath, 'w', encoding='utf-8') as file:
    file.write(template_content)